<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    /*单击行改变当前表格行背景色的颜色样式*/
    .changeColor{
        background-color: #bcddff  !important;
        color: #333333;
    }
    /*重新设置样式*/
    .form-control {
        width: 196px !important;
        height: 34px !important;
        padding: 10px !important;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini"  onload="checkBrowser()">


<!--盘点计划新增模态框-->
<div class="modal fade" id="modal-add-check-plan">
    <div class="modal-dialog" style="width:500px;">
        <div class="modal-content">
            <div class="modal-header" style="padding-bottom: 0px;">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="modal-add-check-plan-title">盘点计划新增</h4>
            </div>
            <div class="modal-body" style="padding-bottom: 5px;padding-top: 0px;">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header">
                            </div>
                            <div class="box-body">
                                <form id="modalForm" class="form-horizontal" role="form">
                                    <div hidden>
                                        <input type="hidden" name="cpnId">
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group" style="height: 60px;">
                                                <label class="form-label col-sm-3"
                                                       style="margin: 0px;padding: 0px;line-height: 35px ">计划盘点时间</label>
                                                <div class="col-sm-9"
                                                     style="margin: 0px;padding: 0px;line-height: 35px;">
                                                    <input name="cpnStart" type="text"
                                                           class="form-control datepicker" style="display: inline-block;width: 100px!important;"
                                                           readonly="readonly"> -
                                                    <input name="cpnEnd" type="text"
                                                           class="form-control datepicker" style="display: inline-block;width: 100px!important;"
                                                           readonly="readonly">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group" style="height: 110px">
                                                <label class="form-label col-sm-3" for="cpnContent"
                                                       style="margin: 0px;padding: 0px;line-height: 35px">
                                                    盘点内容
                                                </label>
                                                <div class="col-sm-9"
                                                     style="margin: 0px;padding: 0px;">
                                                    <textarea type="text" id="cpnContent" name="cpnContent"
                                                              style="resize: none;height: 100px!important;width: 300px!important;"
                                                              class="form-control" maxlength="500" cols="80" rows="7"
                                                              placeholder="请输入盘点内容"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group" style="height: 110px">
                                                <label class="form-label col-sm-3" for="cpnRemark"
                                                       style="margin: 0px;padding: 0px;line-height: 35px">备注</label>
                                                <div class="col-sm-9"
                                                     style="margin: 0px;padding: 0px;text-align:left">
                                                    <textarea type="text" id="cpnRemark" name="cpnRemark"
                                                              style="resize: none;height: 100px!important;width: 300px!important;"
                                                              class="form-control" maxlength="500" cols="80" rows="7"
                                                              placeholder="请输入备注"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group" style="height: 110px">
                                                <label class="form-label col-sm-3" for="cpnParticipants"
                                                       style="margin: 0px;padding: 0px;line-height: 35px">参与人员</label>
                                                <div class="col-sm-9"
                                                     style="margin: 0px;padding: 0px;">
                                                    <textarea type="text" id="cpnParticipants" name="cpnParticipants"
                                                              style="resize: none;height: 100px!important;width: 300px!important;"
                                                              class="form-control" maxlength="500" cols="80" rows="7"
                                                              placeholder="请输入参与人员"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="padding-top: 5px;">
                <button type="button" shiro:hasPermission="purinv:purcheckplan:edit" class="btn btn-info"
                        id="btn-save-commit">确定
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>

</div>
<section class="content-header">
    <h1>库存盘点计划</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        计划编号
                                    </label>
                                    <label class="control-label">
                                        <input name="cpnCode" type="text" class="form-control text" maxlength="255"
                                               placeholder="请输入计划编号"/>
                                    </label>
                                </div>

                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        盘点内容
                                    </label>
                                    <label class="control-label">
                                        <input name="cpnContent" type="text" class="form-control text"
                                               placeholder="请输入盘点内容"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        制作人
                                    </label>
                                    <label class="control-label">
                                        <input name="cpnMaker" type="text" class="form-control text" maxlength="255"
                                               placeholder="请输入制作人信息"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        整体进度
                                    </label>
                                    <label class="control-label">
                                        <select name="cpnStatus"
                                                style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 85px!important;"
                                                class="form-control select">
                                            <option value="" selected>全部</option>
                                            <option value="1">未开始</option>
                                            <option value="2">执行中</option>
                                            <option value="3">已完成</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        计划盘点时间
                                    </label>
                                    <input name="cpnStart" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly"> -
                                    <input name="cpnEnd" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly">
                                </div>
                                <div class="form-group"
                                     style="margin-bottom: 5px">
                                    <button type="button" class="btn btn-success" id="btn-search">搜索
                                    </button>
                                </div>
                            </div>

                        </div>

                    </form>
                </div>
                <div class="row" id="toolbar">
                    <button shiro:hasPermission="purinv:purcheckplan:edit" type="button"
                            class="btn btn-info" id="btn_add_check_plan" style="background-color: #00c0ef; border: #00c0ef;">新增计划
                    </button>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table" class="table table-bordered " width="100%" data-height="400">
                    </table>
                    <h4 id="check-progress-title">盘点整体进度</h4>
                    <table id="check-progress-table" class="table table-bordered " width="100%">
                        <thead>
                        <tr>
                            <th>
                                计划编号
                            </th>
                            <th>
                                盘点计划
                            </th>
                            <th>
                                盘点结果
                            </th>
                            <th>
                                盘点损溢调整
                            </th>
                            <th>
                                损溢表
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr id="check-progress-table-tbody-firstTr"></tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var table;
    var cpnStatus = ["删除", "未开始", "执行中", "已完成"];
    var cpnStatusColor = ["#FFFFFF"," bg-gray"," bg-yellow"," bg-green"];
    var tableCpnStatus = ["", "未开始", "执行中", "已完成"];

    function checkBrowserFun() {
        let is360 = false;
        let isIE = false;
        let isFirefox = false;
        let isChrome = false;
        let isEdge = false;
        let broName = 'Runing';
        let str = '';
        let strStart = 0;
        let strStop = 0;
        let arr = new Array();
        let temp = '';
        let userAgent = window.navigator.userAgent; //包含以下属性中所有或一部分的字符串：appCodeName,appName,appVersion,language,platform
        /*alert(userAgent);*/
        //FireFox
        if (userAgent.indexOf('Firefox') != -1) {
            isFireFox = true;
            /*broName = 'FireFox浏览器';*/
            strStart = userAgent.indexOf('Firefox');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号')

        }
        //Edge
        if (userAgent.indexOf('Edge') != -1) {
            isEdge = true;
            /*broName = 'Edge浏览器';*/
            strStart = userAgent.indexOf('Edge');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号');
        }
        //IE浏览器
        if (userAgent.indexOf('NET') != -1 && userAgent.indexOf("rv") != -1) {
            isIE = true;
            /*broName = 'IE浏览器'; */
            strStart = userAgent.indexOf('rv');
            strStop = userAgent.indexOf(')');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('rv', 'IE').replace(':', '版本号');
        }
        //360极速模式可以区分360安全浏览器和360极速浏览器
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") < 0 && userAgent.indexOf("Firefox") < 0) {
            if (navigator.javaEnabled()) {
                is360 = true;
                broName = '360安全浏览器-极速模式';
            } else {
                is360 = true;
                broName = '360极速浏览器-极速模式';
            }
        }
        //360兼容
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") != -1 && userAgent.indexOf("MSIE") != -1 && userAgent.indexOf("rv") < 0) {
            is360 = true;
            broName = '360兼容模式';
        }
        //Chrome浏览器
        if (userAgent.indexOf('WOW') < 0 && userAgent.indexOf('Chrome') > 0 && userAgent.indexOf("Edg") < 0) {
            isChrome = true;
            /*broName = 'Chrome浏览器';*/
            strStart = userAgent.indexOf('Chrome');
            strStop = userAgent.indexOf(' Safari');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('/', '版本号');
        }
        return isChrome;
    }

    /**
     * 检测浏览器
     * */
    function checkBrowser(){
        if(!checkBrowserFun()){
            alert("尊敬的客户，您使用浏览器不是谷歌浏览器，请使用谷歌浏览器访问本系统！");
            location.href=ctx+"overview/index";
        }
    }

    function loadCheckProgressTable(cpnId) {
        $("#check-progress-title").show();
        $("#check-progress-table").show();
        var rowData = $("#bootstrap-table").bootstrapTable('getRowByUniqueId', cpnId);
        var colorArray = ["#FFFFFF", "#C1C1C1", "#F0AD4E", "#5CB85C"];
        //根据主键获取各节点状态
        // $.post(ctx + 'check/plan/stage', {
        //     cpnId: cpnId
        // }, function (result) {
        //     if (result.type == 'SUCCESS') {
        //
        //     }
        // }, 'json');
        var dispatchUrl = "\\/purchase\\/check\\/plan\\/dispatch"
        var checkResultUrl = "";
        var checkAdjustUrl = "";
        var incomeStatementUrl = "";
        if (rowData.cpnResStatus > 1) {
            if (hasP('purinv:purcheckresult:view')) {
                checkResultUrl = "onclick=\"javascript:location.href=\'" + dispatchUrl + "\\/result\\/" + cpnId + "\'\"";
            }
        }
        if (rowData.cpnAdjStatus != undefined && rowData.cpnAdjStatus > 1) {
            if (hasP('purinv:purcheckadj:view')) {
                checkAdjustUrl = "onclick=\"javascript:location.href=\'" + dispatchUrl + "\\/adjust\\/" + cpnId + "\'\"";
            }
        }
        if (rowData.cpnPalStatus != undefined && rowData.cpnPalStatus > 1) {
            if (hasP('purinv:purchecksub:view')) {
                incomeStatementUrl = "onclick=\"javascript:location.href=\'" + dispatchUrl + "\\/pal\\/" + cpnId + "\'\"";
            }
        }
        $("#check-progress-table-tbody-firstTr").empty();
        $("#check-progress-table-tbody-firstTr").append('<td>' + rowData.cpnCode + '</td>' +
            '<td style="background-color: ' + colorArray[rowData.cpnPlanStatus] + '">' + tableCpnStatus[rowData.cpnPlanStatus] + '</td>' +
            '<td onmouseover="changeCursor(this)" ' + checkResultUrl + ' style="background-color: ' + colorArray[rowData.cpnResStatus] + '">' + tableCpnStatus[rowData.cpnResStatus] + '</td>' +
            '<td onmouseover="changeCursor(this)" ' + checkAdjustUrl + ' style="background-color: ' + colorArray[rowData.cpnAdjStatus] + '">' + tableCpnStatus[rowData.cpnAdjStatus] + '</td>' +
            '<td onmouseover="changeCursor(this)" ' + incomeStatementUrl + 'style="background-color: ' + colorArray[rowData.cpnPalStatus] + '">' + tableCpnStatus[rowData.cpnPalStatus] + '</td>');
    }

    // /**
    //  *@FunctionName: initRangedate
    //  *@Description: 初始化时间范围
    //  *@Author: 徐一贺
    //  *@CreateDate: 2020/4/8 13:28
    //  *@Phone: 18241927380
    //  *@Version: 1.0.0
    //  */
    // function initRangeDate() {
    //     //加载日期范围控件
    //     $('#cpnDateTimeRange').DatePicker({
    //         type: 'rangedate',
    //         // startDate: moment().subtract(3, 'year'),
    //         // endDate: moment(),
    //         ranges: [{
    //             label: "昨天",
    //             startDate: moment().subtract(1, 'day'),
    //             endDate: moment().subtract(1, 'day')
    //         }, {
    //             label: '星期天',
    //             startDate: moment().startOf('week'),
    //             endDate: moment()
    //         }, {
    //             label: '2个星期',
    //             startDate: moment().startOf('week').subtract(1, 'week'),
    //             endDate: moment()
    //         }, {
    //             label: '这个月',
    //             startDate: moment().startOf('month'),
    //             endDate: moment()
    //         }, {
    //             label: '下个月',
    //             startDate: moment().startOf('month').subtract(1, 'month'),
    //             endDate: moment().startOf('month')
    //         }, {
    //             label: '今年',
    //             startDate: moment().startOf('year'),
    //             endDate: moment().startOf('moth')
    //         }]
    //     });
    //     $('#rangeDate').DatePicker({
    //         type: 'rangedate',
    //         // startDate: moment().subtract(3, 'year'),
    //         // endDate: moment(),
    //         ranges: [{
    //             label: "昨天",
    //             startDate: moment().subtract(1, 'day'),
    //             endDate: moment().subtract(1, 'day')
    //         }, {
    //             label: '星期天',
    //             startDate: moment().startOf('week'),
    //             endDate: moment()
    //         }, {
    //             label: '2个星期',
    //             startDate: moment().startOf('week').subtract(1, 'week'),
    //             endDate: moment()
    //         }, {
    //             label: '这个月',
    //             startDate: moment().startOf('month'),
    //             endDate: moment()
    //         }, {
    //             label: '下个月',
    //             startDate: moment().startOf('month').subtract(1, 'month'),
    //             endDate: moment().startOf('month')
    //         }, {
    //             label: '今年',
    //             startDate: moment().startOf('year'),
    //             endDate: moment().startOf('moth')
    //         }]
    //     });
    //     $("#rangeDate").val('');
    //
    // }

    /**更改鼠标样式*/
    function changeCursor(obj) {
        $(obj).css("cursor", "pointer");
    }

    /**
     *@FunctionName: search
     *@Description: 查询
     *@Author: 徐一贺
     *@CreateDate: 2020/4/10 16:10
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function search() {
        js.table.search(table);
    }



    $(function () {
        $("title").html($("title").html()+" —— 外购件库存盘点");
        // initRangeDate();
        //加载列表数据
        table = js.table.init({
            id: 'bootstrap-table',
            url: ctx + "purchase/check/plan/list",
            showColumns: true,
            showExport: false,
            pageSize: 300,
            striped: false,
            uniqueId: "cpnId",
            rowStyle: function (row, index) {
                if (row.cpnStatus == 0) {
                    return {css: {"background": "red", "color": "white"}}
                } else {
                    return {css: {}}
                }
            },
            onClickRow: function (row, $element) {
                loadCheckProgressTable(row.cpnId);
                $('.changeColor').removeClass('changeColor');//移除class
                $($element).addClass('changeColor');//添加class
            },
            onLoadSuccess: function (data) {
                if (data.rows.length > 0) {
                    $("#bootstrap-table tbody tr:first-child").addClass('changeColor');
                    if(data.rows.cpnStatus != 0){
                        loadCheckProgressTable(data.rows[0].cpnId);
                        $("#check-progress-title").show();
                        $("#check-progress-table").show();
                    }
                } else {
                    $("#check-progress-title").hide();
                    $("#check-progress-table").hide();
                }
                $('#bootstrap-table thead th').each(function () {
                    $(this).width(Math.floor($(this).width()));
                });
                $('#bootstrap-table tbody tr:first td').each(function () {
                    $(this).width(Math.floor($(this).width()));
                });
            },
            columns: [
                {
                    title: '序号', field: 'cpnId', width: '40',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '计划编号', field: 'cpnCode', width: '150'},
                {title: '盘点内容', field: 'cpnContent', width: '150'},
                {title: '备注', field: 'cpnRemark', width: '150'},
                {title: '计划盘点时间范围', field: 'cpnDateTimeRange', width: '200'},
                {title: '制作人', field: 'cpnMaker', width: '150'},
                {title: '参与人员', field: 'cpnParticipants'},
                {
                    title: '整体进度', field: 'cpnStatus'
                    , formatter: function (value, row, index) {
                        if(value==undefined){
                            return '';
                        }
                        var html='<label class="badge '+cpnStatusColor[value]+'">'+cpnStatus[value]+'</label>';
                        return html;
                    }
                },
                {
                    title: '操作', field: 'cpnId', width: '180',
                    formatter: function (value, row, index) {
                        var htmlText = "";
                        if (row.cpnPlanStatus != 3 && row.cpnStatus != 0) {
                            if (hasP('purinv:purcheckadd:view')) {
                                htmlText += '<button style="width: 60px" class="btn btn-info btn-xs" onclick="addDetail(' + row.cpnId + ')">添加明细</button>';
                            }
                            if (hasP('purinv:purcheckplan:edit')) {
                                htmlText += '<button style="width: 60px;margin-left: 5px" onclick="showEditPanel(' + row.cpnId + ')" class="btn btn-warning btn-xs" data-id="' + row.ipmId + '">修改</button>';
                                htmlText += '<br><button style="margin-top: 5px;width: 60px" class="btn btn-success btn-xs" onclick="submitCheckPlan(' + row.cpnId + ')">提交</button>';
                                htmlText += '<button style="margin-left: 5px;margin-top: 5px;width: 60px" onclick="removeCheckPlan(' + row.cpnId + ')" class="btn btn-xs btn-danger">删除</button>';
                            }
                        }
                        if (row.cpnPlanStatus == 3) {
                            if (hasP('purinv:purcheckadd:view')) {
                                htmlText += '<button style="width: 60px" class="btn btn-info btn-xs" onclick="viewDetail(' + row.cpnId + ')">查看明细</button>';
                            }
                            if (hasP('purinv:purcheckplan:edit')) {
                                if(row.cpnIsCheckDetailCount==0){
                                    htmlText += '<button style="margin-left: 5px;width: 60px" class="btn btn-primary btn-xs" onclick="revokeCheckPlan(' + row.cpnId + ')">撤销</button>';
                                }
                            }
                        }
                        return htmlText;
                    }
                }
            ]
        });
        /**
         * 表格搜索
         */
        $("#btn-search").on('click', function () {
            js.table.search(table);
        });
        /**
         *@Description: 新增盘点计划
         *@Author: 徐一贺
         *@CreateDate: 2020/4/25 8:01
         *@Phone: 18241927380
         *@Version: 1.0.0
         */
        $("#btn_add_check_plan").on('click', function () {
            //销毁表单验证
            $("#modalForm").data('bootstrapValidator').destroy();
            //置空表单验证
            $('#modalForm').data('bootstrapValidator', null);
            //重新绑定表单验证
            formValidator("modalForm");
            //重置表单内容
            $("#modalForm")[0].reset();
            $("#modalForm [name='cpnId']").val('');

            //打开添加模态框
            $("#modal-add-check-plan-title").text("盘点计划新增");
            js.modal.open("modal-add-check-plan");
        });

        /**
         *@Description: 保存盘点计划
         *@Author: 徐一贺
         *@CreateDate: 2020/4/25 8:01
         *@Phone: 18241927380
         *@Version: 1.0.0
         */
        $("#btn-save-commit").on('click', function () {
            //销毁表单验证
            $("#modalForm").data('bootstrapValidator').destroy();
            //置空表单验证
            $('#modalForm').data('bootstrapValidator', null);
            //重新绑定表单验证
            formValidator("modalForm");
            //验证通过式提交
            js.validSubmit({
                formId: "modalForm",
                url: ctx + "purchase/check/plan/save",
                data: new FormData($("#modalForm")[0]),
                success: function (result) {
                    js.modal.hide("modal-add-check-plan");
                    js.modal.success("保存盘点计划成功！");
                    js.table.refresh(table);
                }
            });
        })
        //加载表单验证
        formValidator("modalForm");
    });


    /**
     *@FunctionName: formValidator
     *@Description: 验证初始化
     *@Author: 徐一贺
     *@CreateDate: 2020/4/25 11:14
     *@Phone: 18241927380
     *@Param: [formId] formId
     *@Version: 1.0.0
     */
    function formValidator(formId) {
        // 验证初始化
        js.validate.init(formId, {
            fields: {
                cpnContent: {
                    validators: {
                        notEmpty: {message: '请输入盘点内容'}
                    }
                }
                // ,
                // cpnRemark: {validators: {notEmpty: {message: '请输入备注'}}},
                // cpnParticipants: {validators: {notEmpty: {message: '请输入参与人员'}}},
                // cpnDateTimeRange: {
                //     validators: {
                //         notEmpty: {message: '请选择预计盘点时间'}
                //     }
                // }
            }
        });
    }

    /**
     *@Description: 显示修改盘点计划面板
     *@Author: 徐一贺
     *@CreateDate: 2020/4/25 9:35
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function showEditPanel(cpnId) {
        //销毁表单验证
        $("#modalForm").data('bootstrapValidator').destroy();
        //置空表单验证
        $('#modalForm').data('bootstrapValidator', null);
        //重新绑定表单验证
        formValidator("modalForm");
        //重置表单内容
        $("#modalForm")[0].reset();
        //根据唯一主键获取该行数据
        var rowData = $("#bootstrap-table").bootstrapTable('getRowByUniqueId', cpnId);
        //使用表单回显，回显数据
        $("#modalForm").fillData(rowData);
        //打开添加模态框（实际用于修改）
        $("#modal-add-check-plan-title").text("盘点计划修改");
        js.modal.open("modal-add-check-plan");
    }

    /**
     *@FunctionName: removeAppy
     *@Description: 删除
     *@Author: 徐一贺
     *@CreateDate: 2020/4/21 13:09
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function removeCheckPlan(cpnId) {
        js.modal.confirm("尊敬的用户，您缺要删除此计划吗？",function () {
            $.post(ctx + 'purchase/check/plan/remove', {
                cpnId: cpnId
            }, function (result) {
                if (result.type == "SUCCESS") {
                    js.table.refresh(table);
                    loadCheckProgressTable(cpnId);
                }
            }, 'json');
        });
    }

    /**
     *@FunctionName: submitCheckPlan
     *@Description: 提交
     *@Author: 徐一贺
     *@CreateDate: 2020/4/21 13:09
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function submitCheckPlan(cpnId) {
        js.modal.confirm("您确认要提交此计划吗？", function () {
            $.post(ctx + 'purchase/check/plan/submit', {
                cpnId: cpnId
            }, function (result) {
                if (result.type == "SUCCESS") {
                    js.table.refresh(table);
                }
            }, 'json');
        });
    }

    /**
     *@FunctionName: submitCheckPlan
     *@Description: 撤销
     *@Author: 徐一贺
     *@CreateDate: 2020/4/21 13:09
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function revokeCheckPlan(cpnId) {
        js.modal.confirm("您确认要撤销此计划吗？", function () {
            $.post(ctx + 'purchase/check/plan/revoke', {
                cpnId: cpnId
            }, function (result) {
                if (result.type == "SUCCESS") {
                    js.modal.success(result.msg);
                    js.table.refresh(table);
                } else {
                    js.modal.warning(result.msg);
                }
            }, 'json');
        });
    }

    /**
     *@FunctionName: addDetail
     *@Description: 跳转到添加明细
     *@Author: 徐一贺
     *@CreateDate: 2020/4/25 13:53
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function addDetail(cpnId) {
        location.href = ctx + "purchase/check/detail/" + cpnId;
    }

    /**
     *@FunctionName: viewDetail
     *@Description: 跳转到查看明细
     *@Author: 徐一贺
     *@CreateDate: 2020/4/25 13:53
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function viewDetail(cpnId) {
        location.href = ctx + "purchase/check/detail/view/" + cpnId;
    }
</script>
</body>
</html>
